#coding=utf-8
'''
Created on 2013-10-27

@author: Ben
线程管理
'''

import BasicThread

thread_map = {}

def addThread(thread):
    thread_map[thread.name] = thread
    
'''
杀死所有BasicThread
'''
def killAllBasicThread():
    for name in thread_map:
        thread = thread_map[name]
        if isinstance(thread, BasicThread.BasicThread):
            thread.killThread()

'''
输出所有线程的状态
'''
def state():
    #包括python自己的线程
#     import threading
#     threadlist = threading.enumerate()
#     print threadlist
    for name in thread_map:
        thread = thread_map[name]
        if thread.isAlive() == 1:
            print "thread %s is alive"%name
        else:
            print "thread %s is not alive"%name